﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Base;
using SportsPlatform.Dto.SportBusiness.CompetitionRuleInfo;
using SportsPlatform.Dto.SportBusiness.GetPaymentOrderInfo;
using SportsPlatform.Dto.SportBusiness.RegistrationInfo;
using SportsPlatform.Filters;
using SportsPlatform.Query.SportBusiness.CompetitionRuleInfo;
using SportsPlatform.Query.SportBusiness.RegistrationInfo;
using SportsPlatform.SportBusiness.ISportBusiness;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 报名管理
    /// </summary>

    [ActionAuthorization]
    [Route("api/[controller]/[action]")]
    public class RegistrationInfoController : SportsPlatformControllerBase
    {
        private IRegistrationInfoService _service;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="service"></param>
        public RegistrationInfoController(IRegistrationInfoService service)
        {
            this._service = service;
        }
        
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="Query"></param>
        [HttpPost]
        public async Task<PagePagingDto<RegistrationInfoListDto>> GetRegistrationInfoList([FromBody] GetRegistrationInfoListQuery Query)
        {
            return await _service.GetRegistrationInfoList(Query);
        }

        /// <summary>
        /// 添加报名
        /// </summary>
        /// <param name="Query"></param>
        [HttpPost]
        public async Task<BaseResultDto> AddRegistrationInfo([FromBody] AddRegistrationInfoQuery Query)
        {
            return await _service.AddRegistrationInfo(Query);
        }

        /// <summary>
        /// 判断用户是否报名 true,已经报名，false没有报名
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> IsRegistrationOrNot([FromBody] IsRegistrationOrNotQuery query)
        {
            return await _service.IsRegistrationOrNot(query);
        }

        /// <summary>
        /// 判断赛事项目参赛队名是否存在，true存在，false不存在
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymousAttribute]
        public async Task<BaseResultDto> IsCompeteTeamOrNot([FromBody]IsCompeteTeamOrNotQuery query)
        {
            return await _service.IsCompeteTeamOrNot(query);
        }

        /// <summary>
        /// 审批数据查询
        /// </summary>
        /// <param name="Query"></param>
        [HttpPost]
        public async Task<ResultDto<ApprovalGetRegistrationInfoDetailsDto>> ApprovalGetRegistrationInfoDetails([FromBody] RegistrationInfoDetailsQuery Query)
        {
            return await _service.ApprovalGetRegistrationInfoDetails(Query);
        }

        /// <summary>
        /// 审批数据
        /// </summary>
        /// <param name="Query"></param>
        [HttpPost]
        public async Task<BaseResultDto> ApprovalRegistrationInfo([FromBody] ApprovalRegistrationInfo Query)
        {
            return await _service.ApprovalRegistrationInfo(Query);
        }

        /// <summary>
        /// 下载excel表
        /// </summary>
        [HttpPost]
        public async Task<ResultDto<string>> ExportRegistrationInfoList([FromBody] GetRegistrationInfoListQuery Query)
        {
            return await _service.ExportRegistrationInfoList(Query);
        }

        /// <summary>
        /// 下载PDF表
        /// </summary>
        [HttpPost]
        public async Task<ResultDto<string>> PDFRegistrationInfoList([FromBody] GetRegistrationInfoListQuery Query)
        {
            return await _service.PDFRegistrationInfoList(Query);
        }

        /// <summary>
        /// 批量审批报名
        /// </summary>
        /// <param name="infos"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> ApprovalRegistrationInfoList([FromBody] ApprovalRegistrationInfos infos)
        {
            return await _service.ApprovalRegistrationInfoList(infos);
        }

    }
}
